<cfcomponent>
	<cffunction name="commentsforfile" access="public" returntype="void" output="yes">
		<cfargument name="page" type="string" required="no" default="#cgi.SCRIPT_NAME#" hint="uses cgi.SCRIPT_NAME to pull up comments based on file">
		<cfquery name="qallcomments" datasource="#request.dsn#">
        SELECT * FROM core_comments
        WHERE file = <cfqueryparam value="#page#" cfsqltype="cf_sql_varchar">
        </cfquery>

		<cfloop query="qallcomments">
        <cfif replyto IS 0>
		<div id="comment">
			<cfoutput>
           	<div id="comment_by">Posted by <strong>#name#</strong> on #dateformat(dateofcomment, "mmmm dd, yyyy")#</div>
        	<div id="comment_post">#comment#</div>
            </cfoutput>
            <cfquery name="qreplies" dbtype="query">
            SELECT * FROM qallcomments
            WHERE replyto = <cfqueryparam value="#qcomments.id#" cfsqltype="cf_sql_integer">
            </cfquery>
            <cfif qreplies.recordcount GT 0>---</cfif>
            <cfoutput query="qreplies">
            <div id="comment_reply">#comment# - #name#</div>
            </cfoutput>
        </div>
		</cfif>
        </cfloop>
	</cffunction>
	<cffunction name="commentsforid" access="public" returntype="string">
		<cfargument name="id" type="id" required="yes" default="0" hint="recordid to match (must be unique)">
		<cfquery name="qallcomments" datasource="#request.dsn#">
        SELECT * FROM core_comments
        WHERE recid = <cfqueryparam value="#id#" cfsqltype="cf_sql_varchar">
        </cfquery>

		<cfloop query="qcomments">
        <cfif replyto IS 0>
		<div id="comment">
			<cfoutput>
           	<div id="comment_by">Posted by <strong>#name#</strong> on #dateformat(dateofcomment, "mmmm dd, yyyy")#</div>
        	<div id="comment_post">#comment#</div>
            </cfoutput>
            <cfquery name="qreplies" dbtype="query">
            SELECT * FROM qallcomments
            WHERE replyto = <cfqueryparam value="#qcomments.id#" cfsqltype="cf_sql_integer">
            </cfquery>
            <cfif qreplies.recordcount GT 0>---</cfif>
            <cfoutput query="qreplies">
            <div id="comment_reply">#comment# - #name#</div>
            </cfoutput>
        </div>
		</cfif>
        </cfloop>
	</cffunction>
	<cffunction name="commentsforuserid" access="public" returntype="string">
		<cfargument name="userid" type="numeric" required="yes" default="0" hint="unique userid">
		<cfquery name="qallcomments" datasource="#request.dsn#">
        SELECT * FROM core_comments
        WHERE userid = <cfqueryparam value="#userid#" cfsqltype="cf_sql_varchar">
        </cfquery>

		<cfloop query="qcomments">
        <cfif replyto IS 0>
		<div id="comment">
			<cfoutput>
           	<div id="comment_by">Posted by <strong>#name#</strong> on #dateformat(dateofcomment, "mmmm dd, yyyy")#</div>
        	<div id="comment_post">#comment#</div>
            </cfoutput>
            <cfquery name="qreplies" dbtype="query">
            SELECT * FROM qallcomments
            WHERE replyto = <cfqueryparam value="#qcomments.id#" cfsqltype="cf_sql_integer">
            </cfquery>
            <cfif qreplies.recordcount GT 0>---</cfif>
            <cfoutput query="qreplies">
            <div id="comment_reply">#comment# - #name#</div>
            </cfoutput>
        </div>
		</cfif>
        </cfloop>
	</cffunction>
	<cffunction name="showform" access="public" returntype="string">
		<cfinclude template="#request.absolutepath#components/comments/frm/comment.cfm">
	</cffunction>    
</cfcomponent>